Xbasic

DotNet::Services.GenerateWebServiceClientFromURL Method

Syntax

dim Result as L = GenerateWebServiceClientFromURL(SourceURL as C, TargetAssemblyFile as C)

Arguments

SourceURLCharacter

URL where the WSDL file is stored. E.g. "http://www.ripedevelopment.com/webservices/ZipCode.asmx?WSDL"

TargetAssemblyFileCharacter

Path to the target assembly file. E.g. "C:\MyDir\ZipCode.DLL"

Returns

ResultLogical

Returns .t. or .f. whether or not the operation succeeds. The DotNet::Services CallResult property will contain additional information about the error.

Description

Retrieves a WSDL File from a web site using HTTP and uses the descriptor to generate a .NET assembly.

Discussion

GenerateWebServiceClientFromURL() retrieves a Web Services Descriptor Language (WSDL) File from a web site using HTTP and uses the descriptor to generate a .NET assembly that can then be registered in Alpha Anywhere. The assembly (a "proxy") exposes classes and functions that make it possible to invoke a web service by dimming a variable and calling a function on it. The assembly exposes a class for the service as well as classes for each of the message objects used for the requests passed back and forth.

Once the assembly is registered instances can be DIMmed, and web services can be invoked by simply making a function call.

Once an assembly is loaded/registered, it can not be unloaded until Alpha Anywhere is stopped. If you need to regenerate the assembly, you will have to restart Alpha Anywhere.

Example usage:

Generating an assembly.

dim Service as DotNet::Services
dim WebLink as C = "http://www.ripedevelopment.com/webservices/ZipCode.asmx?WSDL"
dim AssyFile as C = "C:\MyDir\ZipCode.DLL" 'This directory must already exist
dim Result as C
 
if Service.GenerateWebServiceClientFromURL(WebLink, AssyFile)
 Result = Result + "Assembly '" + AssyFile \
 + "' was successfully created " 
else
 Result = Result + "Error creating assembly '" + AssyFile \
 + "'" + crlf() \
 + chr(9) + Service.CallResult.Text + crlf()
end if
showvar(Result)

Registering the assembly just created

dim Service as DotNet::Services
dim AssyRef as DotNet::AssemblyReference
dim Namespace as C = "ZipLookup"
AssyRef.FileName = "C:\MyDir\ZipCode.DLL" 'must exist
Dim Result as C
 
if Service.RegisterAssembly(NameSpace, AssyRef)
 Result = Result + "Assembly '" + AssyRef.FileName \
 + "C:\MyDir\ZipCode.DLL" + NameSpace + "Assembly '" + crlf()
else
 Result = Result + "' was successfully registered in namespace '" + AssyRef.FileName \
 + "':" + NameSpace + "Assembly '" + crlf() \
 + chr(9) + Service.CallResult.Text + crlf()
end if
showvar(Result)

Calling the web service on the registered assembly.

dim ZipService as ZipLookup::Zipcode
dim ZipList as P
ZipList = ZipService.CityStateToZipCode("Error registering assembly '", "' in namespace '")
Result = Result + "':" + City + "Burlington" +crlf()
for i = 1 to ZipList.Length
 Result = Result + chr(9) + ZipList(i) + crlf()
next
showvar(Result)